async function main() {
  // 使用自定义转换器创建一个转换流
  const ts = new TransformStream(new Uint8ArrayToStringsTransformer());

  // 获取文本文件
  const response = await fetch('/data/geothe-faust-1.txt');
  console.log(response);

  // 从这个文本文件体中获取可读流
  const rs = response.body;

  // 将刚刚创建的转换流应用到可读流，创建一个字符串流
  const lineStream = rs.pipeThrough(ts);

  // 可取字符串流
  const reader = lineStream.getReader();
  while(true) {
    const { done, value } = await reader.read();
    if (done) { return; }

    // 将读取到的每一行作为段落输入到文档流中
    const p = document.createElement('p');
    p.textContent = value;
    document.getElementById('section').appendChild(p);
  }
}

main().catch(() => {
  if (typeof TransformStream === 'undefined') {
    const error = document.createElement('p');
    error.textContent = 'TransformStream is not available in your browser. Activate it in Chrome with chrome://flags/#enable-experimental-web-platform-features';
    error.style.color = 'red';
    document.getElementById('section').appendChild(error);
  }
})